feat: implement gemma3n text model in MLXLLM #346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation of Gemma 3n model for MLXLLM, text only. Based on the reference implementation in mlx-lm:
ml-explore/mlx-lm#258
This code can actually help building the VLM version there #340
cc @DePasqualeOrg
Models
The original MLX weights from
mlx-vlm
are not supported, only weights converted bymlx-lm
are supported.I've made a new collection with Text Only MLX models, i.e.
bf16
and4bit
quantized using this new support.https://huggingface.co/collections/mlx-community/gemma-3n-text-only-lm-6861cf66ddc9a13102996308
Naive benchmarks
Apple M4 Max
mlx-community/gemma-3n-E4B-it-lm-bf16
mlx-community/gemma-3n-E2B-it-lm-bf16
mlx-community/gemma-3n-E4B-it-lm-4bit
mlx-community/gemma-3n-E2B-it-lm-4bit
iPhone 16 Pro
mlx-community/gemma-3n-E4B-it-lm-4bit
mlx-community/gemma-3n-E2B-it-lm-4bit
Notes
gelu_topk
,logit_softcap
) to improve performaneRMSNoScale
can be improved whenMLXFast.rmsNorm
is fixed (allows nil weights)Misc
Demos